package o;

import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

@RequiresApi(21)
class du extends Drawable {
    private ColorStateList ʻ;
    private PorterDuffColorFilter ʼ;
    private boolean ʽ = false;
    private final RectF ˊ;
    private float ˋ;
    private final Rect ˎ;
    private float ˏ;
    private Mode ˏॱ = Mode.SRC_IN;
    private final Paint ॱ;
    private ColorStateList ॱॱ;
    private boolean ᐝ = true;

    du(ColorStateList colorStateList, float f) {
        this.ˋ = f;
        this.ॱ = new Paint(5);
        ˊ(colorStateList);
        this.ˊ = new RectF();
        this.ˎ = new Rect();
    }

    private void ˊ(ColorStateList colorStateList) {
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(0);
        }
        this.ॱॱ = colorStateList;
        this.ॱ.setColor(this.ॱॱ.getColorForState(getState(), this.ॱॱ.getDefaultColor()));
    }

    void ˋ(float f, boolean z, boolean z2) {
        if (f != this.ˏ || this.ʽ != z || this.ᐝ != z2) {
            this.ˏ = f;
            this.ʽ = z;
            this.ᐝ = z2;
            ˊ(null);
            invalidateSelf();
        }
    }

    float ॱ() {
        return this.ˏ;
    }

    public void draw(Canvas canvas) {
        Object obj;
        Paint paint = this.ॱ;
        if (this.ʼ == null || paint.getColorFilter() != null) {
            obj = null;
        } else {
            paint.setColorFilter(this.ʼ);
            obj = 1;
        }
        canvas.drawRoundRect(this.ˊ, this.ˋ, this.ˋ, paint);
        if (obj != null) {
            paint.setColorFilter(null);
        }
    }

    private void ˊ(Rect rect) {
        if (rect == null) {
            rect = getBounds();
        }
        this.ˊ.set((float) rect.left, (float) rect.top, (float) rect.right, (float) rect.bottom);
        this.ˎ.set(rect);
        if (this.ʽ) {
            float ˎ = dr.ˎ(this.ˏ, this.ˋ, this.ᐝ);
            this.ˎ.inset((int) Math.ceil((double) dr.ˋ(this.ˏ, this.ˋ, this.ᐝ)), (int) Math.ceil((double) ˎ));
            this.ˊ.set(this.ˎ);
        }
    }

    protected void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        ˊ(rect);
    }

    public void getOutline(Outline outline) {
        outline.setRoundRect(this.ˎ, this.ˋ);
    }

    void ˏ(float f) {
        if (f != this.ˋ) {
            this.ˋ = f;
            ˊ(null);
            invalidateSelf();
        }
    }

    public void setAlpha(int i) {
        this.ॱ.setAlpha(i);
    }

    public void setColorFilter(ColorFilter colorFilter) {
        this.ॱ.setColorFilter(colorFilter);
    }

    public int getOpacity() {
        return -3;
    }

    public float ˏ() {
        return this.ˋ;
    }

    public void ˏ(@Nullable ColorStateList colorStateList) {
        ˊ(colorStateList);
        invalidateSelf();
    }

    public void setTintList(ColorStateList colorStateList) {
        this.ʻ = colorStateList;
        this.ʼ = ॱ(this.ʻ, this.ˏॱ);
        invalidateSelf();
    }

    public void setTintMode(Mode mode) {
        this.ˏॱ = mode;
        this.ʼ = ॱ(this.ʻ, this.ˏॱ);
        invalidateSelf();
    }

    protected boolean onStateChange(int[] iArr) {
        int colorForState = this.ॱॱ.getColorForState(iArr, this.ॱॱ.getDefaultColor());
        boolean z = colorForState != this.ॱ.getColor();
        if (z) {
            this.ॱ.setColor(colorForState);
        }
        if (this.ʻ == null || this.ˏॱ == null) {
            return z;
        }
        this.ʼ = ॱ(this.ʻ, this.ˏॱ);
        return true;
    }

    public boolean isStateful() {
        return (this.ʻ != null && this.ʻ.isStateful()) || ((this.ॱॱ != null && this.ॱॱ.isStateful()) || super.isStateful());
    }

    private PorterDuffColorFilter ॱ(ColorStateList colorStateList, Mode mode) {
        if (colorStateList == null || mode == null) {
            return null;
        }
        return new PorterDuffColorFilter(colorStateList.getColorForState(getState(), 0), mode);
    }
}
